<?php
/************************FoxPHP威客系统************************/
/*                                                            */
/*  FoxPHP.Com (C)2006-2016 FoxPHP Inc.                       */
/*  This is NOT a freeware, use is subject to license terms   */
/*  FoxPHP威客系统是商业软件,使用于商业用途请购买授权         */
/*  V3.0 2016.3                                               */
/*  foxphp@aliyun.com                                         */
/*  http://www.foxphp.com                                     */
/*                                                            */
/**************************************************************/

//上传文件
namespace Post\Controller;
class UploadController extends \Member\Controller\IndexController {
	
	//上传附件
	public function fileAction(){

		if(intval($_GET['mobile'])){
			//移动
		}else{
			//模块
			$model=new \Upload\Model\FileModel();
			$file=$model->StartUpload();
			if($file){
				$this->ajaxReturn(array('title'=>'上传成功','message'=>'上传成功!','status'=>'ok','refresh'=>false,'id'=>$file['id']),'json');
			}else{
				$this->ajaxReturn(array('title'=>'验证失败','message'=>$model->getError(),'status'=>'error','id'=>0),'json');
			}
		}
	}
	
	//上传图片
	public function imageAction(){

		if(intval($_GET['mobile'])){
			//移动
		}else{
			//模块
			$model=new \Upload\Model\FileModel();
			$file=$model->StartUpload(1);
			if($file){
				$this->ajaxReturn(array('title'=>'上传成功','message'=>'上传成功!','status'=>'ok','refresh'=>false,'id'=>$file['id'],'state'=>'SUCCESS','originalName'=>$file['originalname'],'type'=>$file['type'],'url'=>$file['thumb'],'_url'=>$file['filepath'],'name'=>$file['filename'],'size'=>intval($file['size'])),'json');
			}else{
				$this->ajaxReturn(array('title'=>'验证失败','message'=>$model->getError(),'status'=>'error','id'=>0,'state'=>$model->getError(),'originalName'=>'','url'=>'','name'=>'','size'=>0,'type'=>''),'json');
			}
		}
	}
	
	//删除
	public function deleteAction(){

		if(intval($_GET['mobile'])){
			//移动
		}else{
			//模块
			$id=intval($_POST['id']);
			if($id>0){
				$model=new \Upload\Model\FileModel();
				$result=$model->DeleteUpload($id);
				if($result){
					$this->ajaxReturn(array('title'=>'删除成功','message'=>'删除成功!','status'=>'ok','refresh'=>false),$_POST['datatype']);
				}else{
					$this->ajaxReturn(array('title'=>'验证失败','message'=>$model->getError(),'status'=>'error'),$_POST['datatype']);
				}
			}
		}
	}
	
	//获取未定义文件
	public function undefinedfileAction(){

		if(intval($_GET['mobile'])){
			//移动
		}else{
			//模块
			$model=new \Upload\Model\FileModel();
			$result=$model->UndefinedUpload();
			if($result){
				$this->ajaxReturn(array('title'=>'获取成功','message'=>'获取成功!','status'=>'ok','refresh'=>false,'data'=>$result),$_POST['datatype']);
			}else{
				$this->ajaxReturn(array('title'=>'验证失败','message'=>$model->getError(),'status'=>'error','id'=>0),$_POST['datatype']);
			}
		}
	}
	
	//获取未定义图形
	public function undefinedimageAction(){

		if(intval($_GET['mobile'])){
			//移动
		}else{
			//模块
			$model=new \Upload\Model\FileModel();
			$result=$model->UndefinedUpload(1);
			if($result){
				$this->ajaxReturn(array('title'=>'获取成功','message'=>'获取成功!','status'=>'ok','refresh'=>false,'data'=>$result),$_POST['datatype']);
			}else{
				$this->ajaxReturn(array('title'=>'验证失败','message'=>$model->getError(),'status'=>'error','id'=>0),$_POST['datatype']);
			}
		}
	}
}